﻿<ResourceDictionary 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >

    <!--Style x:Key="{x:Type TreeViewItem}" TargetType="TreeViewItem">
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Top"/>
        <Setter Property="Padding" Value="5,3,15,3"/>
        <Setter Property="Cursor" Value="Arrow"/>
        <Setter Property="IsTabStop" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TreeViewItem">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="Disabled">
                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Header" Storyboard.TargetProperty="(UIElement.Foreground).(SolidColorBrush.Color)">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="#FF999999"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="Selected">
                            <DoubleAnimation Duration="0" Storyboard.TargetName="select_gradient" Storyboard.TargetProperty="Opacity" To="1"/>
                            <DoubleAnimation Duration="0" Storyboard.TargetName="select_highlight" Storyboard.TargetProperty="Opacity" To="1"/>
                        </Storyboard>
                        <Storyboard x:Key="SelectedInactive">
                            <DoubleAnimation Duration="0" Storyboard.TargetName="inactive" Storyboard.TargetProperty="Opacity" To=".2"/>
                        </Storyboard>
                        <Storyboard x:Key="NoItems">
                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpanderButton" Storyboard.TargetProperty="(UIElement.Visibility)">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="Expanded">
                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ItemsHost" Storyboard.TargetProperty="(UIElement.Visibility)">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource Disabled}"/>
                            </Trigger.EnterActions>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource Selected}"/>
                            </Trigger.EnterActions>
                        </Trigger>
                        <Trigger Property="HasItems" Value="False">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource NoItems}"/>
                            </Trigger.EnterActions>
                        </Trigger>
                        <Trigger Property="IsExpanded" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource Expanded}"/>
                            </Trigger.EnterActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="15"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <ToggleButton x:Name="ExpanderButton" IsTabStop="False">
                            <ToggleButton.Template>
                                <ControlTemplate TargetType="ToggleButton">
                                    <Grid x:Name="Root">
                                        <Grid HorizontalAlignment="Right" Margin="2,2,5,2">
                                            <Path x:Name="UncheckedVisual" Height="9" Width="6" HorizontalAlignment="Right" VerticalAlignment="Center" Fill="{StaticResource treeviewArrowUnchecked}" StrokeLineJoin="Miter" Data="M 0,0 L 0,9 L 5,4.5 Z"/>
                                            <Path x:Name="CheckedVisual" Height="6" Width="6" HorizontalAlignment="Right" VerticalAlignment="Center" Fill="{StaticResource treeviewArrowChecked}" StrokeLineJoin="Miter" Opacity="0" Data="M 6,0 L 6,6 L 0,6 Z"/>
                                        </Grid>
                                    </Grid>
                                    <ControlTemplate.Resources>
                                        <Storyboard x:Key="MouseOverOn">
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CheckedVisual" Storyboard.TargetProperty="(Path.Fill)">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource treeviewArrowHover}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                        <Storyboard x:Key="MouseOverOff">
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="UncheckedVisual" Storyboard.TargetProperty="(Path.Fill)">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource treeviewArrowHover}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                        <Storyboard x:Key="Disabled">
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To=".7"/>
                                        </Storyboard>
                                        <Storyboard x:Key="CheckedOn">
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="UncheckedVisual" Storyboard.TargetProperty="Opacity" To="0"/>
                                        </Storyboard>
                                        <Storyboard x:Key="CheckedOff">
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="CheckedVisual" Storyboard.TargetProperty="Opacity" To="1"/>
                                        </Storyboard>
                                    </ControlTemplate.Resources>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Trigger.EnterActions>
                                                <BeginStoryboard Storyboard="{StaticResource MouseOverOn}"/>
                                            </Trigger.EnterActions>
                                            <Trigger.ExitActions>
                                                <BeginStoryboard Storyboard="{StaticResource MouseOverOff}"/>
                                            </Trigger.ExitActions>
                                        </Trigger>
                                        <Trigger Property="IsEnabled" Value="False">
                                            <Trigger.EnterActions>
                                                <BeginStoryboard Storyboard="{StaticResource Disabled}"/>
                                            </Trigger.EnterActions>
                                        </Trigger>
                                        <Trigger Property="IsChecked" Value="True">
                                            <Trigger.EnterActions>
                                                <BeginStoryboard Storyboard="{StaticResource CheckedOn}"/>
                                            </Trigger.EnterActions>
                                            <Trigger.ExitActions>
                                                <BeginStoryboard Storyboard="{StaticResource CheckedOff}"/>
                                            </Trigger.ExitActions>
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </ToggleButton.Template>
                        </ToggleButton>
                        <Rectangle x:Name="select_gradient" Grid.Column="1" Fill="{StaticResource BtnOverFill}" Stroke="{StaticResource selectedStroke}" StrokeThickness="1" RadiusX="2" RadiusY="2" Opacity="0" IsHitTestVisible="False"/>
                        <Rectangle x:Name="select_highlight" Margin="1" Grid.Column="1" Stroke="#A0FFFFFF" Opacity="0"/>
                        <Rectangle x:Name="inactive" Grid.Column="1" Fill="#FF999999" Stroke="#FF333333" StrokeThickness="1" RadiusX="2" RadiusY="2" Opacity="0" IsHitTestVisible="False"/>
                        <Button x:Name="Header" Grid.Column="1" Foreground="{TemplateBinding Foreground}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" Padding="{TemplateBinding Padding}" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Cursor="{TemplateBinding Cursor}" ClickMode="Hover" IsTabStop="False">
                            <Button.Template>
                                <ControlTemplate TargetType="Button">
                                    <ControlTemplate.Resources>
                                        <Storyboard x:Key="Pressed">
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="highlight" Storyboard.TargetProperty="Opacity" To="0.65"/>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="hover_gradient" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                        <Storyboard x:Key="Disabled">
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="content" Storyboard.TargetProperty="Opacity" To=".55"/>
                                        </Storyboard>
                                    </ControlTemplate.Resources>
                                    <Grid>
                                        <Rectangle x:Name="hover_gradient" Fill="{StaticResource hoverGradient}" Stroke="{StaticResource hoverStroke}" StrokeThickness="1" RadiusX="2" RadiusY="2" Opacity="0" IsHitTestVisible="False"/>
                                        <Rectangle x:Name="highlight" Margin="1" StrokeThickness="1" RadiusX="1" RadiusY="1" Opacity="0" IsHitTestVisible="False" Stroke="#FFFFFFFF"/>
                                        <ContentPresenter x:Name="content" Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="Left" VerticalAlignment="Center" Cursor="{TemplateBinding Cursor}"/>
                                    </Grid>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsPressed" Value="True">
                                            <Trigger.EnterActions>
                                                <BeginStoryboard Storyboard="{StaticResource Pressed}"/>
                                            </Trigger.EnterActions>
                                        </Trigger>
                                        <Trigger Property="IsEnabled" Value="False">
                                            <Trigger.EnterActions>
                                                <BeginStoryboard Storyboard="{StaticResource Disabled}"/>
                                            </Trigger.EnterActions>
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Button.Template>
                        </Button>
                        <ItemsPresenter x:Name="ItemsHost" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1" Visibility="Collapsed"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="{x:Type TreeView}" TargetType="TreeView">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource OutsideFontColor}"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Top"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Padding" Value="4"/>
        <Setter Property="Cursor" Value="Arrow"/>
        <Setter Property="IsTabStop" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TreeView">
                    <Grid x:Name="Root">
                        <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2">
                            <ScrollViewer x:Name="ScrollViewer" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" Style="{StaticResource System.Windows.Controls.ScrollViewer}" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                                <ItemsPresenter x:Name="TreeItems"/>
                            </ScrollViewer>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style-->

  <Style x:Key="{x:Type TreeView}" TargetType="TreeView">
    <Setter Property="OverridesDefaultStyle" Value="false" />
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Background" Value="White" />
    <Setter Property="HorizontalAlignment" Value="Stretch"/>
    <Setter Property="VerticalAlignment" Value="Stretch"/>
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
    <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="TreeView">
          <Border Name="Border"  CornerRadius="1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
            <ScrollViewer Focusable="False" CanContentScroll="False" Padding="0" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
              <ItemsPresenter/>
            </ScrollViewer>
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="ExpandCollapseToggleStyle" TargetType="{x:Type ToggleButton}">
			<Setter Property="Focusable" Value="False"/>
			<Setter Property="Width" Value="10"/>
			<Setter Property="Height" Value="16"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type ToggleButton}">
						<Border Width="12" Height="16" Background="Transparent" Padding="0,5,0,5">
							<Path Fill="#FF595959" Stroke="#FF989898" x:Name="ExpandPath" Data="M0,0 L0,6 L6,0 z">
								<Path.RenderTransform>
									<RotateTransform Angle="135" CenterX="3" CenterY="3"/>
								</Path.RenderTransform>
							</Path>
						</Border>
						<ControlTemplate.Triggers>
							<Trigger Property="IsMouseOver" Value="True">
								<Setter Property="Stroke" TargetName="ExpandPath" Value="#FF1BBBFA"/>
								<Setter Property="Fill" TargetName="ExpandPath" Value="#FF595959"/>
							</Trigger>
							<Trigger Property="IsChecked" Value="True">
								<Setter Property="RenderTransform" TargetName="ExpandPath">
									<Setter.Value>
										<RotateTransform Angle="180" CenterX="3" CenterY="3"/>
									</Setter.Value>
								</Setter>
								<Setter Property="Fill" TargetName="ExpandPath" Value="Transparent"/>
								<Setter Property="Stroke" TargetName="ExpandPath" Value="#FF262626"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
    
    <Style TargetType="{x:Type TreeViewItem}" x:Key="{x:Type TreeViewItem}">
	    <Setter Property="Background" Value="Transparent"/>
	    <Setter Property="HorizontalContentAlignment" Value="Left"/>
	    <Setter Property="VerticalContentAlignment" Value="Center"/>
	    <Setter Property="Padding" Value="1,0,0,0"/>
	    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
	    <Setter Property="Template">
		    <Setter.Value>
			    <ControlTemplate TargetType="{x:Type TreeViewItem}">
				    <Grid>
					    <Grid.ColumnDefinitions>
						    <ColumnDefinition MinWidth="12" Width="Auto"/>
						    <ColumnDefinition Width="Auto"/>
						    <ColumnDefinition Width="*"/>
					    </Grid.ColumnDefinitions>
					    <Grid.RowDefinitions>
						    <RowDefinition Height="Auto"/>
						    <RowDefinition/>
					    </Grid.RowDefinitions>
					    <ToggleButton x:Name="Expander" Style="{StaticResource ExpandCollapseToggleStyle}" ClickMode="Press" IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"/>
					    <Border SnapsToDevicePixels="true" x:Name="Bd" Grid.Column="1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
                            <Grid SnapsToDevicePixels="true">
                                <Rectangle x:Name="BackgroundGradientOver" Fill="{StaticResource hoverGradient}" Stroke="{StaticResource hoverStroke}" RadiusX="2" RadiusY="2" Opacity="0"/>
                                <Rectangle x:Name="BackgroundGradientSelectedDisabled" Fill="{StaticResource grayGradient}" Stroke="#7F8E8F8F" RadiusX="2" RadiusY="2" Opacity="0"/>
                                <Rectangle x:Name="BackgroundGradientSelected" Fill="{StaticResource BtnOverFill}" Stroke="{StaticResource selectedStroke}" RadiusX="2" RadiusY="2" Opacity="0"/>
                                <Rectangle x:Name="BackgroundHighlight" Margin="1" Stroke="#A0FFFFFF" RadiusX="1" RadiusY="1"/>
                                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" x:Name="PART_Header" 
                                                  ContentSource="Header" Margin="5,3,3,5"/>
                            </Grid>
					    </Border>
					    <ItemsPresenter x:Name="ItemsHost" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1"/>
				    </Grid>
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientOver" Storyboard.TargetProperty="Opacity" To="0.73"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundGradientOver" Storyboard.TargetProperty="Opacity" To="0"/>
                        </Storyboard>
                        <Storyboard x:Key="SelectedOn">
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientSelected" Storyboard.TargetProperty="Opacity" To="0.84"/>
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientSelectedDisabled" Storyboard.TargetProperty="Opacity" To="1"/>
                        </Storyboard>
                        <Storyboard x:Key="SelectedOff">
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundGradientSelected" Storyboard.TargetProperty="Opacity" To="0"/>
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundGradientSelectedDisabled" Storyboard.TargetProperty="Opacity" To="0"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding Path=IsLoaded, RelativeSource={RelativeSource Self}}" Value="True">
                            <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                            <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                        </DataTrigger>
                        <Trigger Property="IsSelected" Value="true">
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource SelectedOff}" x:Name="SelectedOff_BeginStoryboard"/>
                            </Trigger.ExitActions>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource SelectedOn}" x:Name="SelectedOn_BeginStoryboard"/>
                            </Trigger.EnterActions>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}" x:Name="HoverOff_BeginStoryboard"/>
                            </Trigger.ExitActions>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
                            <Setter Property="Visibility" TargetName="BackgroundGradientSelected" Value="Hidden"/>
                        </Trigger>
                        <Trigger Property="HasItems"
                               Value="false">
                            <Setter TargetName="Expander" Property="Visibility" Value="Hidden"/>
                        </Trigger>
                        <Trigger Property="IsExpanded" Value="false">
                            <Setter TargetName="ItemsHost" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                    <!--ControlTemplate.Triggers>
                        <Trigger Property="HasItems"
                               Value="false">
                            <Setter TargetName="Expander" Property="Visibility" Value="Hidden"/>
                          </Trigger>
                        <Trigger Property="IsExpanded" Value="false">
                            <Setter TargetName="ItemsHost" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="true"/>
                                <Condition Property="IsSelectionActive" Value="false"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers-->
			    </ControlTemplate>
		    </Setter.Value>
	    </Setter>
    </Style>
    
    <Style x:Key="GroupedTreeViewItem" TargetType="{x:Type TreeViewItem}">
        <Setter Property="IsExpanded" Value="True"/>
        <Setter Property="Template">
		    <Setter.Value>
			    <ControlTemplate TargetType="{x:Type TreeViewItem}">
                    <Border Name="Border" Margin="4,1" Padding="3,1" Background="{StaticResource GroupBackgroundBrush}" BorderBrush="#444444" IsHitTestVisible="True" SnapsToDevicePixels="true" BorderThickness="0.6" CornerRadius="3">
                        <Expander Name="Exp" IsExpanded="{Binding IsExpanded, RelativeSource={RelativeSource AncestorType={x:Type TreeViewItem}},Mode=TwoWay}">
                            <Expander.Header>
                                    <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                        x:Name="PART_Header" ContentSource="Header"/>
                            </Expander.Header>
                            <ItemsPresenter x:Name="ItemsHost"/>
                        </Expander>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="GroupedTreeView" TargetType="TreeView">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="ItemContainerStyle" Value="{StaticResource GroupedTreeViewItem}"/>
    </Style>
</ResourceDictionary>